import request from "@/utils/request";
// 登录
export function login(data) {
  return request({
    baseURL: "",
    url: "/dmserver/oauth/login",
    method: "post",
    data: data
  });
}
// 登出
export function logout(token) {
  return request({
    url: " oauth/signOut/" + token,
    method: "get"
  });
}
// 查询表数据列表
export function listData(query) {
  return request({
    url:
      "/api/datasource/selectTableData/" +
      query.pageNumber +
      "/" +
      query.pageSize,
    method: "post",
    data: query
  });
}
// 获取数据集列表数据

export function getTableList(query) {
  return request({
    url:
      "/api/dataset/getDataSetList/" +
      query.pageNumber +
      "/" +
      query.pageSize +
      "/" +
      query.dataSetName,
    method: "get"
  });
}
// 获取模型列表数据

export function getModelList(query) {
  return request({
    url: "/api/project/getModelList/" + query.pageNumber + "/" + query.pageSize,
    method: "get"
  });
}

// 获取日志列表数据
export function getLogList(data) {
  return request({
    url:
      "/operationLog/getOperationLogList/" +
      data.pageNumber +
      "/" +
      data.pageSize,
    method: "post",
    data: data
  });
}

// 验证数据集是否存在
export function checkIsDataSetName(query) {
  return request({
    url: "/api/dataset/existsDataSet/" + query,
    method: "get"
  });
}

// 数据集添加
export function addSetForm(query) {
  return request({
    url: "/api/dataset/insertDataSet",
    method: "post",
    data: query
  });
}
// 新建目标检验
export function checkIsTableName(query) {
  return request({
    url: "/api/datasource/" + query + "/exists",
    method: "get"
  });
}
// model完整验证
export function completeVerification(id) {
  return request({
    url: "/api/project/existsModel/" + id,
    method: "get"
  });
}
// model下载
export function completeDownload(id) {
  return request({
    url: "/api/project/downLoadModel/" + id,
    method: "get",
    responseType: "blob",
    headers: { "Content-Type": "application/json; application/octet-stream" }
  });
}
// model部署
export function completeDploy(data) {
  return request({
    url: "/api/project/deployModelSFTP",
    method: "post",
    data: data
  });
}
// // 日志查询
// export function logSearch(pageNumber,pageSize) {
//   return request({
//     url: "/operationLog/getOperationLogList/" +pageNumber+"/" +pageSize ,
//     method: "post",
//     data:data
//   });
// }
// 模型搜索
export function modelSearch(query) {
  return request({
    url:
      "/api/project/getModelList/" +
      query.pageNumber +
      "/" +
      query.pageSize +
      "/" +
      query.modelName,
    method: "get"
  });
}
// 数据表验证
export function dataSheet(tableName) {
  return request({
    url: "/api/datasource/" + tableName + "/exists",
    method: "get"
  });
}
// 生成上传id
export function generateUpload(data) {
  return request({
    url: "/api/datasource/flat",
    method: "post",
    data: data
  });
}
// 文件上传并同步数据
export function fileUpload(data) {
  return request({
    url: "/api/file/uploadFile",
    method: "post",
    data: data
  });
}
// 创建表结构
export function createTable(data) {
  return request({
    url: "/api/dataset/createTable",
    method: "post",
    data: data
  });
}
// 数据集详情查询
export function datasetDetail(query) {
  return request({
    url:
      "/api/dataset/getDataSetTableDetails/" +
      query.pageNumber +
      "/" +
      query.pageSize +
      "/" +
      query.tableName,
    method: "get"
  });
}
// 数据集子集查询
export function datasubsetList(id) {
  return request({
    url: "/api/dataset/getDataSetChildrenOnlyName/" + id,
    method: "get"
  });
}
// 数据集源数据信息
export function datasubsetInfo(tableName) {
  return request({
    url: "/api/dataset/getDataSetMetaData/" + tableName,
    method: "get"
  });
}
// 子集表新建
export function newSubsetTable(data) {
  return request({
    url: "/api/dataset/createDateSetChildren",
    method: "post",
    data: data
  });
}
// 批量删除数据源管理
export function delDataSource(data) {
  return request({
    url: "/api/datasource/deleteDataSource",
    method: "delete",
    data: data
  });
}
// 日志等级名称
export function getLogName() {
  return request({
    url: "/operationLog/getLevelNameInfo",
    method: "get"
  });
}
// 模块名称
export function getModelName() {
  return request({
    url: "/operationLog/getModelNameList",
    method: "get"
  });
}
// 日志导出
export function exportLog(data) {
  return request({
    url: "/operationLog/exportExcelLog",
    method: "post",
    data: data,
    responseType: "blob",
    headers: { "Content-Type": "application/json; application/octet-stream" }
  });
}
// 数据源名称查询
export function dataNameSearch() {
  return request({
    url: "/api/datasource/getDataSourceNameList",
    method: "get"
  });
}
// 数据集信息编辑
export function editInfo(data) {
  return request({
    url: "/api/dataset/updateDataSetById",
    method: "put",
    data: data
  });
}
// 数据集信息回显
export function getInfoOne(id) {
  return request({
    url: "/api/dataset/getDataSetById/" + id,
    method: "get"
  });
}

//数据集删除
export function delDataArr(data) {
  return request({
    url: "/api/dataset/deleteDataSetById",
    method: "delete",
    data: data
  });
}
//数据集子信息回显
export function getSonDataSource(id) {
  return request({
    url: "/api/dataset/getDataSetById/" + id,
    method: "get"
  });
}
//数据集-表删除
export function delSurface(tableName) {
  return request({
    url: "/api/dataset/dropDataSetChildrenByName/" + tableName,
    method: "delete"
  });
}
//文件目录查询
export function directorySearch(data) {
  return request({
    url: "/api/file/listFilesInDir",
    method: "post",
    data: data
  });
}
//获取文件列名称
export function getFileName(data) {
  return request({
    url: "/api/file/getFileColumnsName",
    method: "post",
    data: data
  });
}
//工具输入输出参数
export function getToolName(val) {
  return request({
    url: "/api/file/getFileParamsInputAndOutPutByName/" + val,
    method: "get"
    // query: val
  });
}
//获取组件输出目录
export function getOutputName(name) {
  return request({
    url: "/api/file/getLinkComponentFileByName/" + name,
    method: "get"
  });
}
//获取上级组件信息
export function getSuperiorInfo(projectId, componentId) {
  return request({
    url: "/api/file/getLinkComponentNameById/" + projectId + "/" + componentId,
    method: "get"
  });
}
// //获取上级组件信息
// export function getSuperiorInfo(projectId, componentId,params) {
//   return request({
//     url: "/api/file/getLinkComponentNameById/" + projectId + "/" + componentId,
//     method: "post",
//     data:params
//   });
// }
//点击树调详情
export function project(currentParentItem) {
  return request({
    url: "api/project/" + currentParentItem + "/child",
    method: "get"
  });
}

//下载
export function downLoadFile(data) {
  return request({
    url: "/api/file/downLoadFile",
    method: "post",
    data: data
  });
}
//运行态工程信息
// export function runInfomation(id) {
export function runInfomation(id, runId) {
  return request({
    // url: "/api/project/getProjectByRun/" + id,
    url:
      id && runId
        ? `/api/project/getProjectByRun/${id}/${runId}`
        : `/api/project/getProjectByRun/`,
    method: "get"
  });
}
//同步运行态
export function syncRunFile(id) {
  return request({
    url: "/api/project/exeuteBeforeSyncProject/" + id,
    method: "get"
  });
}
//保存历史数据
export function saveHistoryList(id) {
  return request({
    url: "/api/project/insertProjectHisInfo/" + id,
    method: "get"
  });
}
//历史数据列表
export function historyList(id) {
  return request({
    url: "/api/project/getProjectHisList/" + id,
    method: "get"
  });
}
//历史数据工程数据
export function historyInfoList(id, projectId) {
  return request({
    url: "/api/project/getProjectHisById/" + id + "/" + projectId,
    method: "get"
  });
}
//工程运行实例
export function runInstance(id) {
  return request({
    url: "/api/project/getRunningProject/" + id,
    method: "get"
  });
}

// 判断两个连线的连接 校验
export function switchCreateLineRelation(data) {
  return request({
    url: "/api/compareComponentFileField",
    method: "post",
    data
  });
}

// 获取部门列表
export function getAllDeptList() {
  return request({
    url: "/oauth/getSysDeptList",
    method: "get"
  });
}

//根据部门id查询用户
export function queryUserFromDeptId(deptId) {
  return request({
    url: "/oauth/getUserInfoByDeptId/" + deptId,
    method: "get"
  });
}

//查询当前登陆用户已授权的工程列表
export function getHasAuthProjectList() {
  return request({
    url: "/api/project/beAuthorProjectList",
    method: "get"
  });
}

//根据项目id查询当前项目下所有的团队协作人员
export function getThisProjectAllTeamMember(projectId) {
  return request({
    url: "/api/project/getProjectTeamName/" + projectId,
    method: "get"
  });
}

//创建新的工程实例
export function createNewEngineeringExample(projectId, instanceName) {
  return request({
    url: `/api/project/createToolRunInstance/${projectId}/${instanceName}`,
    method: "get"
  });
}

//删除单个工程实例
export function DeleteSingleEngineeringExample(projectId, runId) {
  return request({
    url: `/api/project/deleteToolRunInstance/${projectId}/${runId}`,
    method: "delete"
  });
}

//获取用户信息
export function getUserInfo(projectId, runId) {
  return request({
    url: `/oauth/getInfo`,
    method: "get"
  });
}

//修改工具流协作团队
export function modifyTeamMember(data) {
  return request({
    url: "/api/project/updateProjectTeamPerson",
    method: "put",
    data: data
  });
}

//文件转换在文件 在自动运行时的操作
export function fileChangeWhenAutoRun(data) {
  return request({
    url: "/api/project/fileColumnsParse",
    method: "post",
    data: data,
    timeout: 60 * 1000
  });
}

// http://127.0.0.1:8088/dmserver/api/project/getToolProjectInsStausById/1000062/85
//查询运行实例的每个节点的运行状态
export function queryInstanceRunStatus(projectId, runId) {
  return request({
    url: `/api/project/getToolProjectInsStausById/${projectId}/${runId}`,
    method: "get"
  });
}

//查询运行实例的每个节点的运行状态
export function editOrAddInstanceRunStatus(data) {
  return request({
    url: `/api/project/updateToolProjectInsStaus`,
    method: "post",
    data
  });
}
//获取组件工具的文件输出目录
export function getFileDirectory(serverId) {
  return request({
    url: `/api/file/getToolOutFileDirByIdOrPath/${serverId}`,
    method: "get"
  });
}
//获取下级文件目录
export function getSearchSubordinate(data) {
  return request({
    url: `/api/file/listFilesInDir`,
    method: "post",
    data
  });
}
//确认输出文件功能
export function confirmOutputFunction(data) {
  return request({
    url: `/api/project/confirmFileOut`,
    method: "post",
    data
  });
}
//重置按钮
export function resetBtn(projectId, instanceId) {
  return request({
    url: `/api/project/runInstanceReset/${projectId}/${instanceId}`,
    method: "get"
  });
}
//确认输出文件功能-状态
export function confirmFileStatus(projectId, instanceId, componentId) {
  return request({
    url: `/api/project/getConfirmFileOutStatus/${projectId}/${instanceId}/${componentId}`,
    method: "get"
  });
}
